package com.easyjava.qingke.memo;

import com.easyjava.qingke.memo.command.Command;
import com.easyjava.qingke.memo.command.CommandFactory;
import com.easyjava.qingke.memo.command.CommandFactory.CommandCode;
import com.easyjava.qingke.memo.util.MemoConsole;

public class MemoApllication {
	private static MemoApllication instance = null;

	private MemoApllication() {
	}

	public static synchronized MemoApllication getInstance() {

		if (instance == null) {
			instance = new MemoApllication();
		}

		return instance;
	}


	public static void main(String[] args) {

		MemoConsole.println("welecome to here ,you can inpt 'help' for help");
		while (true) {
			String cmd = MemoConsole.prompt("cmd>");

			CommandCode cmdCode = null;
			try {
				cmdCode = CommandCode.valueOf(cmd.toUpperCase());
			} catch (Exception e) {
				MemoConsole.println("你输入了一个不合适的命令,请使用Help查看帮助");
				continue;
			}

			CommandFactory factory = CommandFactory.getFactory();
			Command command = factory.buildCommand(cmdCode);
			command.excute();
		}
	}

}
